var prjId = null;//项目id
var app = null;//vue实例

mui.ready(function(){
   
    //获取项目id
    prjId = location.search.substring(1);
    
    //创建vue实例
    app = new Vue({
        el:'#app',
        data:{
            itemName:'',
            itemCompany:'',
            itemUser1:'',
            itemDepartment:'',
            user1Phone:'',
            itemText:'',

            updatetime:'',
            s1:'',

            itemUser2:'',
            user2Department:'',
            user2Phone:'',
            user2Text:'',

            itemUser3:'',
            user3Department:'',
            user3Phone:'',
            user3Text:'',

            itemFile:'',

            itemImg:[]
        },
        methods:{
            formatTime:function(strTime){ //格式化时间
                var date = new Date(strTime);
                return date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate();
            }
        },
        created:function(){
            //获取vue实例
            var self = this;
            //获取数据
            jQuery.ajax({
                url:OPENAPI.selectByItemId,
                data:{
                    itemID:prjId
                },
                type:'post',
                dataType:"json",
                timeout:5000,
                success:function(data){
                    var item = data.item;
                    
                    self.itemName = item.itemName;
                    self.itemCompany = item.itemCompany;
                    self.itemUser1 = item.itemUser1;
                    self.itemDepartment = item.itemDepartment;
                    self.user1Phone = item.user1Phone;
                    self.itemText = item.itemText;

                    self.updatetime = self.formatTime( item.updatetime );
                    self.s1 = item.s1;

                    self.itemUser2 = item.itemUser2 || '暂无';
                    self.user2Department = item.user2Department || '暂无';
                    self.user2Phone = item.user2Phone || '暂无';
                    self.user2Text = item.user2Text || '暂无';

                    self.itemUser3 = item.itemUser3 || '暂无';
                    self.user3Department = item.user3Department || '暂无';
                    self.user3Phone = item.user3Phone || '暂无';
                    self.user3Text = item.user3Text || '暂无';

                    self.itemFile = item.itemFile || '暂无';

                    if( item.itemImg != '' && item.itemImg != null && item.itemImg != undefined ){
                        self.itemImg = ( item.itemImg ).split('★'); 
                    }
                },
                error:function(error){
                    mui.toast('网络连接异常');
                }
            })
        },
        mounted:function(){
            setTimeout(function(){
                mui.previewImage();
            }, 3000);
        }
    });

    mui('.mui-scroll-wrapper').scroll({
        indicators: true //是否显示滚动条
    });
});